<?php

namespace frontend\frontBundle\Controller\Admin;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;
 /**
  * 
  *Class for login, regist user
 * Author: DucLH
 */
class AduserController extends Controller{
/**
    * 
    * Show list users
    * Author: DucLH
    */
  public function indexAction() {
  	/*	
  	if ($this->get('security.context')->isGranted('ROLE_ADMIN')) {
       	
    }
	$user = $this->get('security.context')->getToken()->getUser();
	*/
  	return $this->render('frontendfrontBundle:Admin/User:index.html.php');
  }

  /**
    * 
    * Show form login
    * Author: DucLH
    */
  public function loginAction() {
  	
  	$request = $this->getRequest();
    $session = $request->getSession();
	
	// get the login error if there is one
    if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
    	$error = $request->attributes->get(
            SecurityContext::AUTHENTICATION_ERROR
        );
    } else {
    	$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
        $session->remove(SecurityContext::AUTHENTICATION_ERROR);
    }
	return $this->render('frontendfrontBundle:Admin/User:login.html.php', array(
                // last username entered by the user
                'last_username' => $session->get(SecurityContext::LAST_USERNAME),
                'error'         => $error,
            ));
  }

  /**
    * 
    * Check login
    * Author: DucLH
    */
  public function checkloginAction() {
   	return $this->render('frontendfrontBundle:Admin/User:checklogin.html.php');
  }

  /**
    * 
    * Destroy session
    * Author: DucLH
    */
  public function logoutAction() {
    return $this->render('frontendfrontBundle:Admin/User:logout.html.php');
  }

  /**
    * 
    * Show form regist user
    * Author: DucLH
    */
  public function registAction() {
    return $this->render('frontendfrontBundle:Admin/User:regist.html.php');
  }

 /**
  * 
  * Regist user complete
  * Author: DucLH
  */
  public function registCompleteAction() {
    return $this->render('frontendfrontBundle:Admin/User:registcomplete.html.php');
  }
  /**
  * 
  * Change Pass
  * Author: DucLH
  */
  public function changepassAction() {
    return $this->render('frontendfrontBundle:Admin/User:changepass.html.php');
  }
  
}